#include<bits/stdc++.h>
using namespace std;
const int maxn=15;
int n,m,T,aps[maxn];
int a[maxn],ans;
int find(int n)
{
    int fun=0;
    for(int i=1;i<n;i++)
        if(aps[i]==aps[n]) fun=i;
    return fun;
}
void countn()
{
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        int p=find(i);
        if(p==0)continue;
        if(a[p]==a[i]) cnt+=a[i];
    }
    ans=max(ans,cnt);
}
void dfs(int deep)
{
    if(deep==n+1)
        return countn();
    aps[deep]=0;
    dfs(deep+1);
    aps[deep]=1;
    dfs(deep+1);
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    scanf("%d",&T);
    while(T--)
    {
        ans=0;
        scanf("%d",&n);
        for(int i=1;i<=n;i++)
            scanf("%d",a+i);
        dfs(1);
        printf("%d\n",ans);
    }
    return 0;
}
